home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13442 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: mail2news.demon.co.uk!tsys.demon.co.uk
  2. From: Tom Wheeley <tomw@tsys.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Can anyone HELP with variable delaration? Please?
  5. Date: Sun, 07 Apr 96 01:42:57 GMT
  6. Organization: City Zen FM
  7. Message-ID: <828841377snz@tsys.demon.co.uk>
  8. References: <4jt07b$dul@news.us.net> <3162119a.43634755@news.ucs.ubc.ca> <4juf2kINNe9v@keats.ugrad.cs.ubc.ca> <3162de71.18703379@news.ucs.ubc.ca>
  9. Reply-To: tomw@tsys.demon.co.uk
  10. X-NNTP-Posting-Host: tsys.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.30
  12. X-Sig-By: Tomsystems Quote v1.2.  (c)1996 Tom Wheeley, tomw@tsys.demon.co.uk
  13. X-Mail2News-Path: tsys.demon.co.uk
  14.  
  15. In article <3162de71.18703379@news.ucs.ubc.ca>
  16.            jamesdf@unixg.ubc.ca "James Fairweather" writes:
  17.  
  18. > >Any variable can be declared constant, including strings:
  19. > >
  20. > >       const char * const str = "Foo";
  21. > >
  22. > >Or do you mean literal constants?
  23. > >
  24. > I'm not sure what the difference is.  I thought the keyword "const"
  25. > was just for the compiler.  If you tried to modify the variable
  26. > declared const, the compiler would complain.  Does it do something
  27. > else with the variable if you declare it const?
  28. > >In what way are integers a suitable alternative representation for string data?> >-- 
  29. > I guess I was being too extreme.  It's just that in high school, when
  30. > we were coding with Pascal, we were encouraged to use strings
  31. > whereever possible.  Don't ask me why; it never occurred to me to ask
  32. > at the time.  And sometimes when I read other people's code,
  33. > espeically people who are used to Pascal, I often see them using
  34. > strings in an if...else situation.  In these cases, a well-name
  35. > #defined constant works better, because you can use switch and the
  36. > comparison is faster.
  37.  
  38. I must say that that sounds appalling!  I would never use a string like that.
  39. (Although I would be interested if someone could point out a useful time for
  40. this).
  41. In Pascal, (well, Borland Pascal for sure) you would use enumerated types.
  42.  
  43. It is true that the Pascal `string' data type does encourage you to use
  44. more strrings than in C.  C actually makes you feel a bit guilty, as you
  45. have to do all that malloc()ing and strcmp() and strcpy() to do things, rather
  46. than a seemingly far less significant `:=', `=' or var myvar: string;
  47.  
  48. .splitbung
  49. -- 
  50. * TQ 1.0 * The 'Just So Quotes'.
  51. "This is a one line proof...if we start sufficiently far to the left."
  52.         -- peter@cbmvax.cbm.commodore.com
  53.